<template>
	<el-dialog title="" width="60%" visible :show-close="false" :append-to-body="true" class="wrap" @close="cancel" :close-on-click-modal="false">
			<!--<div id="">-->
				<i class="el-icon-close close" @click="cancel" style="color: white;z-index:10;"></i>
				<div class="bt">{{this.info.zwm}}的缴费详情</div>
			<!--</div>-->
			<!--<i class="el-icon-close close-top" @click="cancel"></i>-->
			<!--<div style="font-size: 23px;text-align: center;margin-top: 10px;">{{this.info.zwm}} 学生的缴费详情</div>-->
			<div style="width: 100%;overflow: hidden;">
				<el-button type="success" icon="el-icon-caret-left" @click="cancel" size="small" style='float: left;'>返回</el-button>
				<el-button type="danger" v-if="info.islq=='未领取' && info.button=='Y' " icon="d-arrow-left" @click="componentsShow('ly')" size="small" style='float: left;'>领取</el-button>
				<el-button type="danger" v-if="info.islq=='已领取'" @click="componentsShow('qxly')"  size="small" style='float: left;'>取消领取</el-button>
				<div v-if="info.button=='Y'" style="float: right;font-size: 18px;color: red;">领取状态：{{this.info.lqzt}}</div>
			</div>

			<!-- 数据表格展示区域 -->
			<div class="" style="overflow: hidden;">
				<div class="total">
					<p style="font-size: 20px;">1.费用</p>
					<br/>
					<span>已交：￥{{this.info.jes}}</span>
					<!--<span>课程：￥{{this.info.kcje}}</span>-->
					<!--<span>物品：￥{{this.info.wpje}}</span>-->
					<!-- <span>优惠金：￥{{oldTicket}}</span> -->
					<!--<span>合计：￥{{this.info.kcje+this.info.wpje}}</span>-->
					<!-- <div class="total"> -->
					<br/>
					<br/>

					<span :style="tableCellControl(scope1)">未交：￥{{this.info.qf}}</span>
					<!-- </div> -->
				</div>
				<div class="total2">
					<p style="font-size: 20px;">2.支付方式</p>
					<br/>
					<span>
					            直减优惠：{{this.info.zj}} &nbsp;&nbsp;&nbsp;优惠卷：{{this.info.yhj}}
					</span>
              		<br/>
                    <br/>
                    <span>
           			现金：{{this.info.xj}}&nbsp;&nbsp;&nbsp;支付宝：{{this.info.zfbje}}&nbsp;&nbsp;&nbsp;微信：{{this.info.wxje}}&nbsp;&nbsp;&nbsp;银行卡：{{this.info.yhkje}}
         		    </span>
				</div>
			</div>
			<div style="width: 100%;font-size: 16px; margin-bottom: 5px;" v-if="this.lx=='课程'">订单课程列表</div>
			<el-table :data="dataList" :v-loading="false" v-if="this.lx=='课程'" element-loading-text="拼命加载中" border stripe align="center" class="admin-table" :row-class-name="tableRowClassName">

				<el-table-column :prop="v.prop" :label="v.label" v-for="(v,index) in portTitleList1" align="center" show-overflow-tooltip v-if="v.hide != 0" :formatter="v.formatter" :align="v.align || 'center'" :fixed="v.fixed" :class-name="v.columnStyle" :width="v.width" :min-width="v.minWidth" :header-align="v.headerAlign || 'center'">
					<!-- <template scope="scope">

                     <div slot="reference" :style="tableCellControl(scope)">
                         <span v-if="scope.column.property == 'splx'" v-html="scope.row.splx == 1 ? '课时':'物品'"></span>
                         <span v-else>{{ scope.row[scope.column.property] }}</span>

                     </div>
                  </template>  -->
				</el-table-column>
			</el-table>
			<div style="width: 100%;font-size: 16px; margin-bottom: 5px;" v-if="this.lx=='物品'">订单物品列表</div>
			<el-table :data="dataList2" :v-loading="false" v-if="this.lx=='物品'" element-loading-text="拼命加载中" border stripe align="center" class="admin-table" :row-class-name="tableRowClassName">

				<el-table-column :prop="v.prop" :label="v.label" v-for="(v,index) in portTitleList" align="center" show-overflow-tooltip v-if="v.hide != 0" :formatter="v.formatter" :align="v.align || 'center'" :fixed="v.fixed" :class-name="v.columnStyle" :width="v.width" :min-width="v.minWidth" :header-align="v.headerAlign || 'center'">
					<!-- <template scope="scope">

                     <div slot="reference" :style="tableCellControl(scope)">
                         <span v-if="scope.column.property == 'splx'" v-html="scope.row.splx == 1 ? '课时':'物品'"></span>
                         <span v-else>{{ scope.row[scope.column.property] }}</span>

                     </div>
                  </template>  -->
				</el-table-column>
			</el-table>
			<div style="width: 100%;font-size: 16px; margin-bottom: 5px;margin-top: 10px;">订单支付记录</div>
			<el-table :data="dataList1" style="width: 100%;text-align:center;">
				<el-table-column align="center" prop="zje" label="本次支付金额" width="70">
				</el-table-column>
				<el-table-column align="center" label="现金支付" style="text-align: center;">
					<el-table-column align="center" prop="xj" label="现金" width="60">
					</el-table-column>
					<!--<el-table-column align="center" prop="yezf" label="余额" width="60">
					</el-table-column>-->
					<el-table-column align="center" prop="yhj" label="优惠券" width="80">
					</el-table-column>
					<el-table-column align="center" prop="zj" label="直减" width="60">
					</el-table-column>
				</el-table-column>

				<el-table-column align="center" label="第三方支付" style="text-align: center;">
					<el-table-column align="center" prop="zffs" label="支付方式" width="80">
					</el-table-column>
					<el-table-column align="center" prop="zfje" label="金额" width="60">
					</el-table-column>
					<el-table-column align="center" prop="zfkh" label="账号" width="160">
					</el-table-column>
				</el-table-column>

				<el-table-column align="center" prop="note" label="备注" width="">
				</el-table-column>
				</el-table-column>

				<el-table-column align="center" prop="sj" label="支付时间" width="160">
				</el-table-column>
				</el-table-column>

			</el-table>

			<!-- 分页查询区域 -->
			<!-- <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page.sync="pageindex"
            :page-sizes="pagesizes"
            :page-size="pagesize"
            :layout="layout"
            :total="total"
            class="class-page">
        </el-pagination> -->

			<!-- 各个组件显示区域 -->

			<!-- 动画加载 -->
			<LoadingComponent v-show="isLoading"></LoadingComponent>

			<!-- 子路由显示区域 -->
			<router-view class="port-view"></router-view>
			<LyComponent v-if="portComponents.ly.toggle" @close="componentsHide" :params="this.params"></LyComponent>
			<QxlyComponent v-if="portComponents.qxly.toggle" @close="componentsHide" :params="this.params"></QxlyComponent>
		</el-dialog>
</template>

<script>
	import qs from 'qs'
	import { mapState } from 'vuex'
	import LoadingComponent from 'components/loading'
	import LyComponent from './ly'
	import QxlyComponent from './qxly'
	export default {
		components: {
			LoadingComponent,
			LyComponent,
			QxlyComponent
		},
		props: ['params'],
		data() {
			return {
				scope1: '',
				ischanged: true,
				id: '',
				lx:'',
				info: {
					kcje: '',
					wpje: '',
					oldTicket: '',
					je: '',
					qf: '',
					zj: '',
					yhj: '',
					zfyuer: '',
					xj: '',
					lx:'',
					zfbje: '',
					wxje: '',
					yhkje: '',
					islq: '',
				},
				/*组件区域*/
				portComponents: {
					singleDelete: {
						type: 'singleDelete',
						toggle: false,
						params: '',
						data: {
							index: '',
							type: 'single',
							title: '此操作将删除该班级, 是否继续?'
						}
					},
					multipleDelete: {
						type: 'multipleDelete',
						toggle: false,
						params: '',
						data: {
							index: '',
							type: 'multiple',
							title: '此操作将删除您选中的班级, 是否继续?'
						}
					},
					add: {
						type: 'add',
						toggle: false,
						params: '',
						data: {}
					},
					edit: {
						type: 'edit',
						toggle: false,
						params: '',
						data: {}
					},
					info: {
						type: 'info',
						toggle: false,
						params: '',
						data: {}
					},
					ly: {
						type: 'ly',
						toggle: false,
						params: '',
						data: {}
					},
					qxly: {
						type: 'qxly',
						toggle: false,
						params: '',
						data: {}
					}
				},

				multipleDelNum: '', //获取批量选择的数据
				dataList: [], //表格数据
				dataList1: [], //表格数据
				dataList2:[],

				/*
				    prop :  接口参数名
				    label : 接口中文名
				    hide : 是否隐藏这一列
				    align : 这一列对齐顺序 ： left,right,center
				    headerAlign : 这一列表头对齐方式 ： left,right,center
				*/
				portTitleList: [
					{
						prop: 'flmc',
						label: '物品分类',
						hide: 1,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '',
						headerAlign: 'center',
						// formatter: function(row,column) {
						//     return row.splx == 1 ? '课时' : '物品'
						// }
					},
					{
						prop: 'type',
						label: '商品类型',
						hide: 1,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '',
						headerAlign: 'center',
						// formatter: function(row,column) {
						//     return row.splx == 1 ? '课时' : '物品'
						// }
					},
					{
						prop: 'mc',
						label: '商品名称',
						hide: 1,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '',
						headerAlign: 'center'
					},
					{
						prop: 'jcjg',
						label: '基础价格',
						hide: 0,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '',
						headerAlign: 'center'
					},
					{
						prop: 'jcjg',
						label: '单价',
						hide: 1,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '',
						headerAlign: 'center'
					},
					
					{
						prop: 'number',
						label: '数量',
						hide: 1,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '',
						headerAlign: 'center'
					},
					{
						prop: 'kcsl',
						label: '库存数量',
						hide: 1,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '',
						headerAlign: 'center'
					},{
						prop: 'dw',
						label: '单位',
						hide: 0,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '',
						headerAlign: 'center',
//						formatter: function(row, column) {
//							return row.type == "课程" ? '次数' : '套'
//						}
				},
					{
						prop: 'zk',
						label: '折扣',
						hide: 1,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '',
						headerAlign: 'center',
						formatter: function(row, column) {
							return row.zk
						}
					},
					{
						prop: 'zj',
						label: '合计',
						hide: 1,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '',
						headerAlign: 'center',
//						formatter: function(row, column) {
//							return row.jcjg * row.number * row.zk * 0.01
//						}
					}
				],
				portTitleList1: [
					{
						prop: 'kcmc',
						label: '课程名称',
						hide: 1,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '',
						headerAlign: 'center'
					},
				
					{
						prop: 'jcjg',
						label: '单价',
						hide: 1,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '',
						headerAlign: 'center'
					},
					{
						prop: 'cns',
						label: '数量',
						hide: 1,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '',
						headerAlign: 'center'
					}, 
				
					{
						prop: 'zk',
						label: '折扣',
						hide: 1,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '',
						headerAlign: 'center',
						formatter: function(row, column) {
							return row.zk
						}
					},
					{
						prop: 'jg',
						label: '合计',
						hide: 1,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '',
						headerAlign: 'center',
//						formatter: function(row, column) {
//							return row.jcjg * row.number * row.zk * 0.01
//						}
					}
				],
				portBntList: [ //接口按钮列表
					{
						name: '编辑',
						type: 'edit'
					},
					{
						name: '详情',
						type: 'info'
					},
					{
						name: '删除',
						type: 'singleDelete'
					}
				],
				/*动画加载*/
				isLoading: true, //动画加载
				searchLoading: false, //搜索按钮触发按钮动画
				/*模糊搜索条件*/
				inputjkname: '', //  接口名称,
				/*分页属性设置*/
				layout: 'total, sizes, prev, pager, next, jumper', //组件布局
				pageindex: 1, //当前分页页码
				pagesizes: [12, 24, 36, 72], //显示个数的选择器选项
				pagesize: 12, //每页显示条目数
				total: 0, //总条数
				dropDownData: '', //
			}
		},
		created() {
			//加载页面时调用
//			this.$store.dispatch('changeTitle', '缴费详情'); //修改title
			//			this.$store.dispatch('changeRouterIndex', '/cost/payjl'); //修改路由
			this.isLoading = true; //动画开始
			console.log(this.params,'00000000000')
			if(this.params.row){
				if(this.params.row.sid) {
					this.id = this.params.row.sid;
				} else {
					this.id = this.params.row.orderid;
				}
			}
			else if(this.params){
				    this.id = this.params.orderid;
			}
			else{
				this.id = this.params.id;
			}
			this.search(); //分页获取默认数据
		},
		mounted() {
			this.isLoading = false; //动画结束
		},
		methods: {
			tableRowClassName(row, index) { //隔行变色颜色设置
				/*if ( index%4 == 0) {
				    return "table-cell-green";
				}else if( index%4 == 1 ){
				    return "table-cell-yellow";
				}else if( index%4 == 2 ){
				    return "table-cell-red";
				}else{
				    return "table-cell-blue"
				}*/
			},
			tableCellControl(scope1) { //表格单元格控制CSS样式
				if(this.info.qf > 0) {
					return {
						color: "red",
					}
				}
			},
			cancel() {
				this.$emit('close', {type: 'info',cancel: this.ischanged});
				this.$emit('close', {type: 'info1',cancel: this.ischanged});
				this.$emit('close', {type: 'lq',cancel: this.ischanged});
			},
			search() { //查询搜索触发事件
				var logininfo = JSON.parse(localStorage.logininfo);
				var params3 = qs.stringify({
					yhid: logininfo.id + '',
					xxid: logininfo.xxid + '',
					orderid: this.id + '',
				});
				this.axios.post(this.$store.state.api + 'order/ordersp', params3)
					.then(res => {
						console.log(res,'kkkkkkk')
						this.dataList = res.data.data.kc;
						this.dataList2 = res.data.data.wp;
						this.info = res.data.data.info[0];
						this.lx=res.data.data.info[0].lx;
						this.dataList1 = res.data.data.xfjl;
						this.searchLoading = false;
					}).catch(res => {
						this.searchLoading = false;
					})
			},
			handleSizeChange(val) { //每页显示条数触发事件
				this.pagesize = val;
				this.pageindex = 1;
				this.search();
			},
			handleCurrentChange(val) { //分页触发事件
				this.search();
			},
			componentsShow(type, data) { //显示组件
				if(type == 'qxly'){
					this.portComponents.qxly.toggle = true;
				}
				if(type == 'ly'){
					for(var j in this.dataList2){
						if(this.dataList2[j].number > this.dataList2[j].kcsl){
							this.$message.warning("库存数量不足无法领取!");
							return
						}
					}
					for(let i in this.portComponents) {
						if(type == this.portComponents[i].type) {
							this.portComponents[i].toggle = true;
							this.portComponents[i].params = data;
							if(this.portComponents[i].data.type == 'single') {
								this.portComponents[i].data.index = data.row.id
							} else if(this.portComponents[i].data.type == 'multiple') {
								this.portComponents[i].data.index = this.multipleDelNum;
							} else {
								return;
							}
							return;
						}
					}
				}
				
			},
			componentsHide(setting) { //关闭组件 
				this.search();
				for(let i in this.portComponents) {
					if(setting.type == this.portComponents[i].type) {
						this.portComponents[i].toggle = false;
						if(setting.type == 'ly' && !setting.cancel) {
							this.ischanged = false;
							this.search();
							//this.$emit('close', { type: 'info', cancel: false });
						} else if(!setting.cancel) {
							this.search();
						}
						return;

					}
				}
			}
		}
	}
</script>
<style lang="less" scoped>
	.wrap {
		/*text-align: center;*/
	}

	.bt {
		position: absolute;
		width: 100%;
		height: 50px;
		margin: 0 auto;
		top: 0;
		left: 0;
		background: #50BFFF;
		color: white;
		text-align: left;
		line-height: 50px;
		font-size: 16px;
		padding-left: 15px;
	}
	
	
	
	
	
	.total {
		text-align: left;
		float: left;
		margin: 20px 0;
		font-size: 15px;
		span {
			margin: 0 10px;
		}
		p {
			// font-size: 20px;
			margin: 0 10px;
		}
	}
	
	.total2 {
		width: 40%;
		text-align: left;
		float: right;
		margin: 20px 0;
		font-size: 15px;
		span {
			margin: 0 10px;
		}
		p {
			margin: 0 10px;
		}
	}
</style>